Developer's Workshop: Relapse

by Douglas Wright

Two weeks ago I digressed about my lack of time awareness.  This week I'm coming to you live from the planet Koozbain.  Where we will witness the mating ceremony of the Koozbainian Hooziwutzle.  Wait, that was my childhood.  I told you I have a problem with time.  That's why I've decided to continue with the Ticker example and refine my system_time() based ticker. I use a shared area to pass ticks between applications.  <SEGUE>But why, you ask, do you get to write so many articles in the newletter?  Well, this week I moved up in the rotation to help out Steven Beaulieu who spent the week in Paris at Comdex IT.</SEGUE>

<SHAMELESS PLUG>That's right, as a Developer Technical Support Engineer, you get to do all sorts of exciting things like travel to exotic places and hang out with geeky foreigners.  Other times you are entertained by investigating mind bending bug reports, explaining new APIs, or exploring a developer's quirky code.  My favorite part is getting up in front of the audience either in a Newsletter or live and in person at the upcoming Be Developers' Conference and trying to explain why I enjoy staying up late writing code for the BeOS.  It's great fun!</SHAMELESS_PLUG> <PLEA FOR HELP>If you would like to live the wild life and feel up to the challenge, submit a resume to jobs@be.com with Developer Technical Support in the subject.</PLEA FOR HELP>  Watch the Be want ads for this and other exciting opportunities.

http://www.be.com/aboutbe/jobs/index.html

Last time I challenged you to yank out the TCIn class and the chaser class and stick them in another app. Then send a message from the chaser app to the ticker app with the port_id of the chaser.  See the first article to catch up if you missed it:

http://www.be.com/aboutbe/benewsletter/volume_II/Issue4.html#Workshop

In this week's sample code, I've done just that for you.  This week's archive is appropriately named timecodeticker2:

ftp://ftp.be.com/pub/preview/media_kit/timecodeticker2.zip

It includes timecodeticker from last time with some new code to setup communication with other apps.  It also includes an example listener app that syncs to the timecodeticker.  I've also changed some of the internals of the timecodeticker.  Now rather than passing all the information directly on a port, it uses a shared area to communicate data from one app to many.  write_port() gets less efficient as the messages get larger.  Using a shared area allows me to pass just an index into the memory and this keeps the jitter lower.  A chaser can then get all the info it needs when it receives a tick, on it's own thread of time.  For more information on using areas, check out the BeBook/KernalKit/Areas:

http://www.be.com/documentation/be_book/kernel/areas.html

I would also like to clarify my use of 30 frames per second in last week's example.  NTSC television runs slightly slower than 30 frames per second, at 29.97fps.  I was being misleading by dismissing this point and using a tick period that was calculated straight from 30fps.  For more information on video and timecodes, check out Steve Sakoman's Video Basics articles (1 and 2) and the reference books he recommends:

http://www.be.com/aboutbe/benewsletter/volume_II/Issue5.html#Insight
http://www.be.com/aboutbe/benewsletter/Issue93.html#Insight

With the BTimecode class, we've created a timecode_type, so I've changed the tcticker constructor to take a timecode_type and use a period based on that.  I've also added a multiplier parameter to the ticker so that you can have it shuttle both forward and backward at continuous speeds from 0 to 3 times the frame rate.  Next time I'll show you how to hook up the new Slider class from R3 as a shuttle controller.

Have fun coding, and I look forward to seeing you at the BeDC in March!

